package com.wetao.lib_common.greendao.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 9): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 9;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        AnswerCardDao.createTable(db, ifNotExists);
        AssistantExamDao.createTable(db, ifNotExists);
        AssistantExamOnlineDao.createTable(db, ifNotExists);
        AssistantQuestionDao.createTable(db, ifNotExists);
        AssistantQuestionOnlineDao.createTable(db, ifNotExists);
        ExamListenDao.createTable(db, ifNotExists);
        ExaminationPointItemDao.createTable(db, ifNotExists);
        FlexiImgDao.createTable(db, ifNotExists);
        HttpCacheItemDao.createTable(db, ifNotExists);
        NoticeItemDao.createTable(db, ifNotExists);
        PageGridDao.createTable(db, ifNotExists);
        PagePictureDao.createTable(db, ifNotExists);
        PagePictureGridDao.createTable(db, ifNotExists);
        PagePictureOnlineDao.createTable(db, ifNotExists);
        PenOffLineGridInfoDao.createTable(db, ifNotExists);
        PenOffLineGridInfoChildDao.createTable(db, ifNotExists);
        QuestionGridDao.createTable(db, ifNotExists);
        QuestionRevisionItemDao.createTable(db, ifNotExists);
        ReadPushRecordDao.createTable(db, ifNotExists);
        StudentIdToEnDao.createTable(db, ifNotExists);
        UserItemDao.createTable(db, ifNotExists);
        WireExamDao.createTable(db, ifNotExists);
        WireQuestionDao.createTable(db, ifNotExists);
        WireQuestionPictureDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        AnswerCardDao.dropTable(db, ifExists);
        AssistantExamDao.dropTable(db, ifExists);
        AssistantExamOnlineDao.dropTable(db, ifExists);
        AssistantQuestionDao.dropTable(db, ifExists);
        AssistantQuestionOnlineDao.dropTable(db, ifExists);
        ExamListenDao.dropTable(db, ifExists);
        ExaminationPointItemDao.dropTable(db, ifExists);
        FlexiImgDao.dropTable(db, ifExists);
        HttpCacheItemDao.dropTable(db, ifExists);
        NoticeItemDao.dropTable(db, ifExists);
        PageGridDao.dropTable(db, ifExists);
        PagePictureDao.dropTable(db, ifExists);
        PagePictureGridDao.dropTable(db, ifExists);
        PagePictureOnlineDao.dropTable(db, ifExists);
        PenOffLineGridInfoDao.dropTable(db, ifExists);
        PenOffLineGridInfoChildDao.dropTable(db, ifExists);
        QuestionGridDao.dropTable(db, ifExists);
        QuestionRevisionItemDao.dropTable(db, ifExists);
        ReadPushRecordDao.dropTable(db, ifExists);
        StudentIdToEnDao.dropTable(db, ifExists);
        UserItemDao.dropTable(db, ifExists);
        WireExamDao.dropTable(db, ifExists);
        WireQuestionDao.dropTable(db, ifExists);
        WireQuestionPictureDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(AnswerCardDao.class);
        registerDaoClass(AssistantExamDao.class);
        registerDaoClass(AssistantExamOnlineDao.class);
        registerDaoClass(AssistantQuestionDao.class);
        registerDaoClass(AssistantQuestionOnlineDao.class);
        registerDaoClass(ExamListenDao.class);
        registerDaoClass(ExaminationPointItemDao.class);
        registerDaoClass(FlexiImgDao.class);
        registerDaoClass(HttpCacheItemDao.class);
        registerDaoClass(NoticeItemDao.class);
        registerDaoClass(PageGridDao.class);
        registerDaoClass(PagePictureDao.class);
        registerDaoClass(PagePictureGridDao.class);
        registerDaoClass(PagePictureOnlineDao.class);
        registerDaoClass(PenOffLineGridInfoDao.class);
        registerDaoClass(PenOffLineGridInfoChildDao.class);
        registerDaoClass(QuestionGridDao.class);
        registerDaoClass(QuestionRevisionItemDao.class);
        registerDaoClass(ReadPushRecordDao.class);
        registerDaoClass(StudentIdToEnDao.class);
        registerDaoClass(UserItemDao.class);
        registerDaoClass(WireExamDao.class);
        registerDaoClass(WireQuestionDao.class);
        registerDaoClass(WireQuestionPictureDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}
